package com.xhd.db;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.Driver;

import javax.naming.InitialContext;
import javax.sql.DataSource;

import com.xhd.exception.DatabaseException;

public class ExtDBPool
 implements DBPool, Serializable
{
private static final long jm51 = 1L;
private DBConfig jm53;
private DaoMonitor jm54;

protected ExtDBPool(DBConfig paramDBConfig)
{
  this.jm53 = paramDBConfig;
  this.jm54 = DaoMonitor.getInstance();
}

public int getIdleSize()
{
  return 0;
}

public int getPoolSize()
{
  return 0;
}

public int getTranLevel(boolean paramBoolean)
{
  return this.jm53.getTranLevel(paramBoolean);
}

public int getUsableSize()
{
  return 0;
}

public boolean freeAllConn()
{
  return false;
}

public int getUseSize()
{
  return 0;
}

public String getId()
{
  return this.jm53.getId();
}

public int getDBType()
{
  return this.jm53.getDBType();
}

public void freeConnection(DBConn paramDBConn)
{
  if (paramDBConn == null)
    return;
  this.jm54.counterSub();
  paramDBConn.release();
  paramDBConn = null;
}

public DBConn getConnection()
  throws DatabaseException
{
  DataSource localDataSource = null;
  try
  {
    InitialContext localInitialContext = new InitialContext();
    if (localInitialContext != null)
      localDataSource = (DataSource)localInitialContext.lookup(this.jm53.getURL());
  }
  catch (Exception localException1)
  {
    throw new DatabaseException(30072, this.jm53.getName(), localException1.toString());
  }
  if (localDataSource != null)
    try
    {
      Connection localConnection = localDataSource.getConnection();
      if (localConnection != null)
      {
        this.jm54.counterAdd();
        DBConn localDBConn = new DBConn(this, localConnection, this.jm53);
        localDBConn.setCheckConn(this.jm53.isCheckConn());
        return localDBConn;
      }
    }
    catch (Exception localException2)
    {
      throw new DatabaseException(30072, this.jm53.getName(), localException2.toString());
    }
  if (localDataSource == null)
    throw new DatabaseException(30073, this.jm53.getURL());
  return null;
}

public DBConn getInnerConnection()
  throws DatabaseException
{
  return getConnection();
}

public void setConfig(DBConfig paramDBConfig)
{
  this.jm53 = paramDBConfig;
}

public void setDriver(Driver paramDriver)
{
}
}
